package com.kehongborui.fliggy.queue;

import com.kehongborui.fliggy.util.JedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zhang peng yang ming
 * @CopyRight (C) http://www.csdn.com
 * @brief 爬虫对应的消息队列
 * @email 122162005@qq.com
 * @date 2018-09-10
 */
@Component
public class VideoUrlQueue {
    @Autowired
    private JedisUtil jedisUtil;

    private static final String KEY = "video_url_queue";

    /**
     * 向video_url_queue放入数据
     * @param o
     */
    public void push(Object o) {
        jedisUtil.lPush(KEY, o);
    }

    /**
     * 获取当前队列的长度
     * @return
     */
    public long length() {
        return jedisUtil.len(KEY);
    }

    public <T>T pop(Class<T> clazz) {
        return jedisUtil.rPop(KEY, clazz);
    }
}
